package com.etheart.model.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Access entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "_access", catalog = "etheart")
public class Access implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Long id;
	private Access access;
	private String url;
	private String accessname;
	private Short isShow;
	private Set<Role> roles = new HashSet<Role>(0);
	private Set<Access> accesses = new HashSet<Access>(0);

	// Constructors

	/** default constructor */
	public Access() {
	}

	/** full constructor */
	public Access(Access access, String url, String accessname, Short isShow,
			Set<Role> roles, Set<Access> accesses) {
		this.access = access;
		this.url = url;
		this.accessname = accessname;
		this.isShow = isShow;
		this.roles = roles;
		this.accesses = accesses;
	}

	// Property accessors
	@Id
	@GeneratedValue
	@Column(name = "id", unique = true, nullable = false)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pid")
	public Access getAccess() {
		return this.access;
	}

	public void setAccess(Access access) {
		this.access = access;
	}

	@Column(name = "url", length = 200)
	public String getUrl() {
		return this.url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@Column(name = "accessname", length = 100)
	public String getAccessname() {
		return this.accessname;
	}

	public void setAccessname(String accessname) {
		this.accessname = accessname;
	}

	

	@Column(name = "is_show")
	public Short getIsShow() {
		return this.isShow;
	}

	public void setIsShow(Short isShow) {
		this.isShow = isShow;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "accesses")
	public Set<Role> getRoles() {
		return this.roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "access")
	public Set<Access> getAccesses() {
		return this.accesses;
	}

	public void setAccesses(Set<Access> accesses) {
		this.accesses = accesses;
	}

}